<?php

//logger

class Logger {
    const LOG_INFO = '/logs/info%s.log';
    const LOG_ERROR = '/logs/error%s.log';

    function __construct() {
    }

    public static function info($message)
    {
        $file = array();

        if (is_file(sprintf(APP_ROOT_DIR . self::LOG_INFO, date('Y_m')))) {
          $file = file(sprintf(APP_ROOT_DIR . self::LOG_INFO, date('Y_m')));
        }

        $file[] = "\r\n" . print_r($message,true);
        file_put_contents(sprintf(APP_ROOT_DIR . self::LOG_INFO, date('Y_m')), $file);
    }

    public static function error($message) {
        $file = array();

        if (is_file(sprintf(APP_ROOT_DIR . self::LOG_ERROR, date('Y_m')))) {
          $file = file(sprintf(APP_ROOT_DIR . self::LOG_ERROR, date('Y_m')));
        }

        $file[] = "\r\n" . date('Y-m-d H:i:s') . print_r($message, true);
        file_put_contents(sprintf(APP_ROOT_DIR . self::LOG_ERROR, date('Y_m')), $file);
    }
}